<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String orderNo = request.getParameter("orderNo");
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description" />
<meta content="B2B电商平台" name="keyword" />

<title>B2B电商平台.订单详情</title>
<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/global.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/pro.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/proManage.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css" type="text/css"></link>
<link rel="stylesheet" type="text/css" href="<%=path%>/include/pagination/page.css" media="all">
<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/mmt_trading.css" />
<link rel="stylesheet" type="text/css" href="http://style.org.hc360.com/js/build/source/widgets/wij/hc.wijmo.css" />
<link rel="stylesheet" type="text/css" href="http://style.org.hc360.com/js/build/source/widgets/wij/hc.wijcalendar.css" />
<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script src="<%=path %>/include/wijmo/external/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/external/globalize.min.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/external/cultures/globalize.cultures.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijpopup.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijcalendar.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path%>/include/pagination/jquery.pagination.js"></script>
<script type="text/javascript" src="<%=path%>/include/pagination/init.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/doT.min.js"></script>
<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/json2.js"></script>
<script src="<%=path%>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>

<style type="text/css">

.colnums-2-ab-b {
	float: left;
	width: 100%;
	height: auto;
	font-size: 12px !important;
}

.listed_tb_k th.t1 {
	width: 44%;
	border-right: 0px solid #fff;
	padding: 0 5px;
}

.listed_tb_k th.t2 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t3 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t4 {
	width: 12%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t5 {
	width: 12%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t6 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t7 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k tbody td.t2 .pic_50 {
	border: 1px solid #FFF;
	width: 50px;
	height: 50px;
	display: table-cell;
	vertical-align: middle;
	text-align: center;
	background-color: #fff;
}

.t4 {
	border-right: 1px solid #ddd;
}

.t5 {
	border-right: 1px solid #ddd;
}

.t6 {
	border-right: 1px solid #ddd;
}

.t7 {
	border-right: 1px solid #ddd;
}

#ajaxSerieslist td {
	border: 1px solid #ddd;
}

thead th {
	border: 1px solid #ddd;
	padding: 4px;
}

.sear {
	border: 1px solid #e0e0e0;
	background: #f5f5f5;
	margin-top: 10px;
	height: 80px;
	line-height: 40px;
	font-size: 14px;
}

ul li{list-style: none;}
.track-rcol{width: 96%; border: 1px solid #eee;}
.track-list{margin: 20px; padding-left: 5px; position: relative;}
.track-list li{position: relative; padding: 9px 0 0 25px; line-height: 18px; border-left: 1px solid #d9d9d9; color: #999;}
.track-list li.first{color: red; padding-top: 0; border-left-color: #fff;}
.track-list li .node-icon{position: absolute; left: -6px; top: 50%; width: 11px; height: 11px; background: url(<%=path %>/include/images/order-icons.png)  -21px -72px no-repeat;}
.track-list li.first .node-icon{background-position:0 -72px;}
.track-list li .time{margin-right: 20px; position: relative; top: 4px; display: inline-block; vertical-align: middle;}
.track-list li .txt{max-width: 600px; position: relative; top: 4px; display: inline-block; vertical-align: middle;}
.track-list li.first .time{margin-right: 20px; }
.track-list li.first .txt{max-width: 600px; }

</style>

<script type="text/javascript">
	$(document).ready(function() {
		_reHeight("rightFrame","contentDiv");
		
		_queryList();
	});

	function _orderDetail(){
		var className = $("#curtm").attr('class');
		if(className == "undefined"||className == null||className == ""){
			$("#curtm").removeClass().addClass("sel_current"); 
			$("#befm").removeClass(); 
			$("#thressfm").removeClass();
		}
		$("#order3").val("q3");
		$("#msgDiv").show();
		$("#buyerDiv").show();
		$("#orderDiv").show();
		$("#deliverDiv").hide();
		$("#discountDetail").hide();
	}

	function _deliverDetail(){
		var className = $("#befm").attr('class');
		if(className == "undefined"||className == null||className == ""){
			$("#befm").removeClass().addClass("sel_current"); 
			$("#curtm").removeClass(); 
			$("#thressfm").removeClass(); 
		}
		$("#order3").val("h3");
		$("#msgDiv").hide();
		$("#buyerDiv").hide();
		$("#orderDiv").hide();
		$("#discountDetail").hide();
		queryDeliverList();
		$("#deliverDiv").show();
	}
	function _discountDetail(){
		var className = $("#thressfm").attr('class');
		if(className == "undefined"||className == null||className == ""){
			$("#thressfm").removeClass().addClass("sel_current"); 
			$("#befm").removeClass(); 
			$("#curtm").removeClass(); 
		}
		$("#order3").val("h3");
		$("#msgDiv").hide();
		$("#buyerDiv").hide();
		$("#orderDiv").hide();
		$("#deliverDiv").hide();
		queryDiscountDetail();
		$("#discountDetail").show();
	}
	
    var pagination;
	function _queryList(){
  		var url = "<%=path %>/orderList/getOrderListByOrderNo.do?orderNo=<%=orderNo%>";
  		pagination = _initPagination({'pageId':'pagination', 'cKey':'toOrderList','url': url, 'rows': 10, 'callback':_initDataList});
	}
	
	function _initDataList(data) {
 		var d = data.rows;
 		var total = data.total;
		var str = "";
		$("#ajaxSerieslist").empty();
		var addressSpan = '';
		for(var i=0;i<d.length;i++){
			$("#createTime").html(d[i].CREATE_TIME);
			$("#createTimeDiscount").html(d[i].CREATE_TIME);
			var num = d[i].products.length;//单个订单商品个数
			if(d[i].products.length>0){
				for(var j = 0;j<num;j++){
					str +="<tr>";
					str +="		<td  style='text-align:center;vertical-align: middle;'>";
					str +="			<div  style='float:left;padding: 6px;'>";
					if(d[i].products[j].PRODUCT_PIC==undefined){
						str += "        		<img src='<%=path%>/download/error/nopicture.jpg' width='50' height='43.5' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
					} else {
						str +=" 				<img src='"+d[i].products[j].PRODUCT_PIC+"' width='50' height='50' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
					}
					str +=" 		</div>";
					str +=" 		<div  style='text-align: left;float:left;vertical-align: middle;padding-top:15px;'>";
					str +=" 			<p>"+ d[i].products[j].PRODUCT_NAME +"</p>";
					str +=" 		</div>";
					str +=" 	</td>";
					str +=" 	<td style='text-align:center;vertical-align: middle' >"+ d[i].products[j].PRODUCT_PRICE +"</td>";
					str +="		<td style='text-align:center;vertical-align: middle' >"+ d[i].products[j].SELL_AMOUNT +"</td>";
					str +="		<td style='text-align:center;vertical-align: middle' >";
					if(d[i].products[j].APPLY_STATUS=="0"){
						str +="申请退款";
					} else if(d[i].products[j].APPLY_STATUS=="1"){
						if(d[i].products[j].PAY_STATUS=="1"){
							str +="退款成功";
						} else {
							str +="申请退款";
						}
					} if(d[i].products[j].APPLY_STATUS=="2"){
						str +="退款失败";
					}
					str +="		</td>";
					if(num>0&&j==0){
						str +="		<td style='text-align:center;vertical-align: top;line-height:55px' rowspan='"+num+"'>"+ d[i].USER_NAME +"</td>";
						str +="		<td style='text-align:center;vertical-align: top;line-height:55px' rowspan='"+num+"'>";
						str += 	d[i].ORDER_STATUS_NODE ;
						str += "</td>";
						str +="		<td style='text-align:center;vertical-align: top;padding-top: 15px;' rowspan='"+num+"'><b>"+ d[i].SUM_REAL_MONEY +"</b>";
						str +="			<br/><span style='color: #6c6c6c;font-family: verdana;'>(含快递:￥"+d[i].DELIVER_MONEY+")</span>";
						str +="		</td>";
					}
					str +="</tr>";
					$("#tel").html(d[i].CON_TEL);
					if(d[i].CON_MESSAGE!=""){
						$("#CON_MESSAGE").html(d[i].CON_MESSAGE);
						$("#msgDiv").show();
					}
					$("#nicheng").html(d[i].USER_NAME);
					var area = d[i].PROVINCE+"&nbsp;"+d[i].CITY+"&nbsp;"+d[i].COUNTY;
					$("#diqu").html(area);
					$("#address").html(d[i].CON_ADDRESS);
					$("#orderStatus").html(d[i].ORDER_STATUS_NODE);
					addressSpan = area + '&nbsp;' + d[i].CON_ADDRESS +"【"+d[i].USER_NAME+"&nbsp;"+d[i].CON_TEL+"】";
				}
			}
		}	
		$("#addressSpan").html(addressSpan);
		$("#ajaxSerieslist").append(str);
		_reHeight("rightFrame", "contentDiv");
	 }
	
	
	function queryDeliverList(){
		var orderNo = '<%=orderNo%>';
		$.ajax({
	 		type:"POST",
			url:"<%=path%>/orderList/queryDeliverList.do",
			data: {
				orderNo:orderNo
			},
			dataType:"json",
			async : false, //同步执行
			success:function(data){
				var d = data.rows;
				$("#deliveryShow").empty();
				var str = '';
				for(var i=0;i<d.length;i++){
					if(i == 0){
						str += '<li class="first">';
						str += '	<i class="node-icon"></i>';
						str += '	<span class="time">【'+d[i].STATUS_NAME+'】' + d[i].LOGISTICS_TIME + '</span>';
						str += '	<span class="txt">' + d[i].LOGISTICS_INTO + '</span>';
						str += '</li>';
					}else {
						str += '<li>';
						str += '	<i class="node-icon"></i>';
						str += '	<span class="time">【'+d[i].STATUS_NAME+'】' + d[i].LOGISTICS_TIME + '</span>';
						str += '	<span class="txt">' + d[i].LOGISTICS_INTO + '</span>';
						str += '</li>';
					}
				}
				if(str==""){
					str += '<li class="first">';
					str += '	<i class="node-icon"></i>';
					str += '	<span class="time">暂无物流信息</span>';
					str += '</li>';
				}
				$("#deliveryShow").append(str);
			}
	 	});
	}
	
	function _reHeight() {
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height() + 40;
		main.height(mainheight);
	}
	
	function _returnPage(){
		var begTime = $("#begTime").val();
		var endTime = $("#endTime").val();
		window.location.href='<%=path %>/orderReview/toOrderReviewListPage.do?begTime='+begTime+'&endTime='+endTime;
	}
	
	function queryDiscountDetail(){
		var url = "<%=path %>/orderList/getDiscountList.do?orderNo=<%=orderNo%>";
		pagination = _initPagination({'pageId':'pagination', 'cKey':'toOrderList','url': url, 'rows': 10, 'callback':_initDiscountDataList});
		//window.location.href='<%=path %>/orderList/toDiscountDetailPage.do?orderNo=<%=orderNo%>&createTime='+$("#createTime").html();
	}
	
	function _initDiscountDataList(data) {
 		var d = data.rows;
 		var orderList = d[0];
 		var orderCount = orderList.length;
 		var discountList = d[1];
 		var discountCount = discountList.length;
		$("#discountDetailList").empty();
		var addressSpan = '';
		var str = '';
		for(var i=0; i < orderCount; i++){
			if(i == 0){
				//第一条商品信息
				str += "<tr>";
				str += "	<td style='text-align:center;vertical-align:middle' >"+ orderList[i].PROMOTION_PRICE +"</td>";
				str += "	<td  style='text-align:center;vertical-align:middle;'>";
				str += "		<div  style='float:left;padding: 6px;'>";
				if(orderList[i].PRODUCT_PIC==undefined){
					str += "		<img src='<%=path%>/download/error/nopicture.jpg' width='50' height='43.5' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
				} else {
					str += "		<img src='" + orderList[i].PRODUCT_PIC+"' width='50' height='50' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
				}
				str += "		</div>";
				str += "		<div  style='text-align: left;float:left;vertical-align:middle;padding-top:15px;'>";
				str += "			<p>"+ orderList[i].PRODUCT_NAME +"</p>";
				str += "		</div>";
				str += "	</td>";
				str += "	<td style='text-align:center;vertical-align:middle' >"+ orderList[i].PRODUCT_PRICE +"</td>";
				str += "	<td style='text-align:center;vertical-align:middle' >"+ orderList[i].PROMOTION_PRICE + "*" + orderList[i].SELL_AMOUNT +"</td>";
				str += "	<td style='text-align:left;vertical-align:middle;padding-left:4px;' rowspan='"+orderCount+"' >";
				if(parseInt(discountCount) > parseInt(0)){
					for(var j = 0; j < discountCount; j++){
						if(j != 0){
							str += '<br>';
						}
						str += '<span>';
						str += '&nbsp;' + (j+1) + '、活动名称：' + discountList[j].YH_NAME + '，优惠方式：';
						if(discountList[j].YH_TYPE == '1'){
							str += '使用优惠券，';
						}else if(discountList[j].YH_TYPE == '2'){
							str += '满减，';
						}else if(discountList[j].YH_TYPE == '3'){
							str += '满返，';
						}else if(discountList[j].YH_TYPE == '4'){
							str += '订单折扣，';
						}
						str += '优惠金额：' +　discountList[j].YH_MONEY + '元';
						str += '</span>';
					}
				}else {
					str += "&nbsp;无优惠记录";
				}
				str += "	</td>";
				str += "</tr>";
			}else{
				str += "<tr>";
				str += "	<td style='text-align:center;vertical-align:middle' >"+ orderList[i].PROMOTION_PRICE +"</td>";
				str += "	<td  style='text-align:center;vertical-align:middle;'>";
				str += "		<div  style='float:left;padding: 6px;'>";
				if(orderList[i].PRODUCT_PIC==undefined){
					str += "		<img src='<%=path%>/download/error/nopicture.jpg' width='50' height='43.5' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
				} else {
					str += "		<img src='" + orderList[i].PRODUCT_PIC+"' width='50' height='50' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
				}
				str += "		</div>";
				str += "		<div  style='text-align: left;float:left;vertical-align:middle;padding-top:15px;'>";
				str += "			<p>"+ orderList[i].PRODUCT_NAME +"</p>";
				str += "		</div>";
				str += "	</td>";
				str += "	<td style='text-align:center;vertical-align:middle' >"+ orderList[i].PRODUCT_PRICE +"</td>";
				str += "	<td style='text-align:center;vertical-align:middle' >"+ orderList[i].PROMOTION_PRICE + "*" + orderList[i].SELL_AMOUNT +"</td>";
				str += "</tr>";
			}
		}	
		$("#discountDetailList").append(str);
	 }
	
</script>
</head>

<body style="font-family: '微软雅黑'">
	<div id="contentDiv" style="padding:5px; width:99%;">
		<input type="hidden" id="begTime" name="begTime" value="${begTime }">
		<input type="hidden" id="endTime" name="endTime" value="${endTime }">
		<div class="colnums-2-ab-b">
			<div class="sear" style="width:99%;padding-bottom: 10px;height:40px;background-color: #FAFAFA;overflow: hidden;">
			<div style="width:85.5%;float:left;border-right: 1px dashed #E0E0E0;">
				<div style="font-weight:bold;margin-left: 10px;height:50px;line-height:50px;">当前订单状态：<span id="orderStatus"></span></div>
			</div>
			<div style="float:left;width:14%;height:40px;">
				<div style="text-align:center;height:40px;line-height:40px;border:0px solid blue;">
					<button id="queryBtn" class="orange_search_btn3" onclick="_returnPage()" style="margin-top:10px;height:35px;">返回</button>				
				</div>
			</div>
			</div>
			<p class="progra"></p>
			<input name="order3" id="order3" type="hidden" value="" />
			<div class="tag_x" style="padding: 0px; width: 100%;">
				<a id="curtm" href="javascript:_orderDetail();" class="sel_current" style="cursor:pointer;">订单信息</a> 
				<a id="befm" href="javascript:_deliverDetail();" style="cursor:pointer;">收货和物流信息</a>
				<a id="thressfm" href="javascript:_discountDetail();" style="cursor:pointer;">优惠详情</a>
			</div>
			<div id="msgDiv" style="margin-top:5px;width:100%;padding:1%;border:none;border-bottom:1px solid #ccc;display:none;">
				<span style="font-weight:bold;height:30px;line-height:30px;display:inline-block;">买家留言：</span><span id="CON_MESSAGE"></span>
			</div>
			<div id="buyerDiv" style="width:100%;border:1px solid #ccc;padding:1%;border:none;border-bottom:1px solid #ccc;">
				<span style="font-weight:bold;height:30px;line-height:30px;display:inline-block;">买家信息</span>
				<table cellspacing="0" cellpadding="0" width="100%">
					<tr>
						<td colspan="3" style="height:30px;text-align:left;vertical-align:middle">昵称：<span id="nicheng"></span></td>
					</tr>
					<tr>
						<td style="height:30px;text-align:left;vertical-align:middle">所在地区：<span id="diqu"></span></td>
						<td style="height:30px;text-align:left;vertical-align:middle">联系电话：<span id="tel"></span></td>
						<td style="height:30px;text-align:left;vertical-align:middle">&nbsp;</td>
					</tr>
					<tr>
						<td style="height:30px;text-align:left;vertical-align:middle">地址：<span id="address"></span></td>
						<td style="height:30px;text-align:left;vertical-align:middle">&nbsp;</td>
						<td style="height:30px;text-align:left;vertical-align:middle">&nbsp;</td>
					</tr>
				</table>
			</div>
			<div id="orderDiv" class="listed_tb_k" style="padding:1%;margin-top:0px;width:99.5%;border:none;">
				<span style="font-weight:bold;height:30px;line-height:30px;display:inline-block;">订单信息</span>
				<table cellspacing="0" cellpadding="0" width="100%" style="border-top:none;">
					<tr>
						<td style="height:30px;text-align:center;vertical-align:middle">
							订单号：<span id="orderNo"><%=orderNo %></span>
						</td>
						<td style="height:30px;text-align:center;vertical-align:middle">
							交易流水号：<span id="transactionId"></span>
						</td>
						<td style="height:30px;text-align:center;vertical-align:middle">
							创建时间：<span id="createTime"></span>
						</td>
					</tr>
				</table>
				<table cellspacing="0" cellpadding="0" width="100%">
					<thead>
						<tr>
							<th style="text-align:center;vertical-align:middle;width:20%;">宝贝</th>
							<th style="text-align:center;vertical-align:middle;width:10%;">单价</th>
							<th style="text-align:center;vertical-align:middle;width:10%;">数量</th>
							<th style="text-align:center;vertical-align:middle;width:6%;">售后</th>
							<th style="text-align:center;vertical-align:middle;width:10%;">买家</th>
							<th style="text-align:center;vertical-align:middle;width:10%;">交易状态</th>
							<th style="text-align:center;vertical-align:middle;width:10%;">实收款</th>
						</tr>
					</thead>
					<tbody id="ajaxSerieslist">
					</tbody>
				</table>
			</div>
			<div id="deliverDiv" style="display:none;margin-top:5px;width:100%;padding:1%;border:none;">
				<span style="display:inline-block;font-weight:bold;height:40px;line-height:40px;">物流信息：</span><br>
				<span style="display:inline-block;height:30px;line-height:30px;">收货地址：<span id="addressSpan"></span></span><br>
				<div class="track-rcol">
					<div class="track-list">
						<ul id="deliveryShow">
						</ul>
					</div>
				</div>
			</div>
			<div id="discountDetail" style="width:100%;display:none;">
				<div  style="margin-top:5px;width:100%;padding:1%;border:none;">
					<div style="height:40px;line-height:40px;font-size:14px;margin-left:2px;">
						<span style="font-weight:bold;height:30px;line-height:30px;display:inline-block;">订单编号：</span><span id="orderNo"><%=orderNo %></span>
						<span style="margin-left:40px;font-weight:bold;height:30px;line-height:30px;display:inline-block;">成交时间：</span><span id="createTimeDiscount"></span>
					</div>
				</div>
				<div  class="listed_tb_k" style="padding:1%;margin-top:0px;width:99.5%;border:none;">
					<table cellspacing="0" cellpadding="0" width="100%">
						<thead>
							<tr>
								<th style="text-align:center;vertical-align:middle;width:10%;" nowrap>订单价格</th>
								<th style="text-align:center;vertical-align:middle;width:20%;" nowrap>宝贝</th>
								<th style="text-align:center;vertical-align:middle;width:10%;" nowrap>宝贝价格</th>
								<th style="text-align:center;vertical-align:middle;width:15%;" nowrap>成交价格*数量</th>
								<th style="text-align:center;vertical-align:middle;width:45%;" nowrap>优惠内容</th>
							</tr>
						</thead>
						<tbody id="discountDetailList">
						</tbody>
					</table>
				</div>
			</div>
			
			<div class="sort_page">
				<div class="bottom_page">
					<div id="pagination"></div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
